package com.wb3.organizer.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.wb3.organizer.dao.ContactDAO;
import com.wb3.organizer.model.Account;
import com.wb3.organizer.model.Contact;

public class ContactDAOImpl implements ContactDAO {

	private HibernateTemplate ht;

	public HibernateTemplate getHt() {
		return ht;
	}

	public void setHt(HibernateTemplate ht) {
		this.ht = ht;
	}

	public void save(Contact contact) {
		ht.save(contact);
	}

	public void update(Contact contact) {
		ht.update(contact);
	}

	public void delete(Contact contact) {
		ht.delete(contact);
	}

	@SuppressWarnings("unchecked")
	public List<Contact> getAll(Account account) {
		return ht.find("from Contact c where c.account = ?", account);
	}

	public Contact getContactById(int con_id) {
		return ht.get(Contact.class, con_id);
	}

}
